package pers.qianyu.month_202101.date_20210117;

import pers.qianyu.util.model.*;

/**
 * 160. 相交链表
 * https://leetcode-cn.com/problems/intersection-of-two-linked-lists/
 *
 * @author mizzle rain
 * @date 2021-01-17 14:59
 */
public class GetIntersectionNode {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if (headA == null || headB == null) return null;
        ListNode p1 = headA, p2 = headB;
        while (p1 != p2) {
            if (p1 != null) p1 = p1.next;
            else p1 = headB;
            if (p2 != null) p2 = p2.next;
            else p2 = headA;
        }
        return p1;
    }

    public static void main(String[] args) {
        System.out.println(null == null);
    }
}
